package cn.stylefeng.guns.modular.sakana.devopsdohostmachine.controller;

import cn.stylefeng.guns.modular.sakana.devopsdohostmachine.entity.DevopsDoHostMachine;
import cn.stylefeng.guns.modular.sakana.devopsdohostmachine.pojo.request.DevopsDoHostMachineRequest;
import cn.stylefeng.guns.modular.sakana.devopsdohostmachine.service.DevopsDoHostMachineService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 主机表控制器
 *
 * @author sakanayy
 * @date 2023/06/29 15:15
 */
@RestController
@ApiResource(name = "主机表")
public class DevopsDoHostMachineController {

    @Resource
    private DevopsDoHostMachineService devopsDoHostMachineService;

    /**
     * 添加
     *
     * @author sakanayy
     * @date 2023/06/29 15:15
     */
    @PostResource(name = "添加", path = "/devopsDoHostMachine/add")
    public ResponseData<DevopsDoHostMachine> add(@RequestBody @Validated(DevopsDoHostMachineRequest.add.class) DevopsDoHostMachineRequest devopsDoHostMachineRequest) {
        devopsDoHostMachineService.add(devopsDoHostMachineRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除
     *
     * @author sakanayy
     * @date 2023/06/29 15:15
     */
    @PostResource(name = "删除", path = "/devopsDoHostMachine/delete")
    public ResponseData<?> delete(@RequestBody @Validated(DevopsDoHostMachineRequest.delete.class) DevopsDoHostMachineRequest devopsDoHostMachineRequest) {
        devopsDoHostMachineService.del(devopsDoHostMachineRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑
     *
     * @author sakanayy
     * @date 2023/06/29 15:15
     */
    @PostResource(name = "编辑", path = "/devopsDoHostMachine/edit")
    public ResponseData<?> edit(@RequestBody @Validated(DevopsDoHostMachineRequest.edit.class) DevopsDoHostMachineRequest devopsDoHostMachineRequest) {
        devopsDoHostMachineService.edit(devopsDoHostMachineRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看详情
     *
     * @author sakanayy
     * @date 2023/06/29 15:15
     */
    @GetResource(name = "查看详情", path = "/devopsDoHostMachine/detail")
    public ResponseData<DevopsDoHostMachine> detail(@Validated(DevopsDoHostMachineRequest.detail.class) DevopsDoHostMachineRequest devopsDoHostMachineRequest) {
        return new SuccessResponseData<>(devopsDoHostMachineService.detail(devopsDoHostMachineRequest));
    }

    /**
     * 获取列表
     *
     * @author sakanayy
     * @date 2023/06/29 15:15
     */
    @GetResource(name = "获取列表", path = "/devopsDoHostMachine/list")
    public ResponseData<List<DevopsDoHostMachine>> list(DevopsDoHostMachineRequest devopsDoHostMachineRequest) {
        return new SuccessResponseData<>(devopsDoHostMachineService.findList(devopsDoHostMachineRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author sakanayy
     * @date 2023/06/29 15:15
     */
    @GetResource(name = "分页查询", path = "/devopsDoHostMachine/page")
    public ResponseData<PageResult<DevopsDoHostMachine>> page(DevopsDoHostMachineRequest devopsDoHostMachineRequest) {
        return new SuccessResponseData<>(devopsDoHostMachineService.findPage(devopsDoHostMachineRequest));
    }

}
